package top.ysez.controller;

import lombok.extern.slf4j.Slf4j;

/**
 * 02实现Runnable
 *
 * @author YsEz
 * @version V1.0.0
 * @date 2022/7/5 21:55
 */
@Slf4j
public class Thread02 {
  public static void main(String[] args) {
    // 1.使用匿名内部类的写法,Thread实现了Runnable
    Thread thread01 =
        new Thread(
            new Runnable() {
              @Override
              public void run() {
                log.info("子线程t1");
              }
            });
    thread01.start();
    // 2.使用lambda表达式
    Thread thread02 =
        new Thread(
            () -> {
              log.info("子线程t2");
            });
    thread02.start();
    // 3.简化
    Thread thread03 = new Thread(() -> log.info("子线程t3"));
    thread03.start();
    log.info("主线程结束");
  }
}
